package com.java.service.impl;

import com.java.entity.Warehouseinfo;
import com.java.dao.WarehouseinfoDao;
import com.java.service.WarehouseinfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Warehouseinfo)表服务实现类
 *
 * @author makejava
 * @since 2021-01-20 18:54:58
 */
@Service("warehouseinfoService")
public class WarehouseinfoServiceImpl implements WarehouseinfoService {
    @Resource
    private WarehouseinfoDao warehouseinfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param wId 主键
     * @return 实例对象
     */
    @Override
    public Warehouseinfo queryById(Integer wId) {
        return this.warehouseinfoDao.queryById(wId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Warehouseinfo> queryAllByLimit(int offset, int limit) {
        return this.warehouseinfoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param warehouseinfo 实例对象
     * @return 实例对象
     */
    @Override
    public Warehouseinfo insert(Warehouseinfo warehouseinfo) {
        this.warehouseinfoDao.insert(warehouseinfo);
        return warehouseinfo;
    }

    /**
     * 修改数据
     *
     * @param warehouseinfo 实例对象
     * @return 实例对象
     */
    @Override
    public Warehouseinfo update(Warehouseinfo warehouseinfo) {
        this.warehouseinfoDao.update(warehouseinfo);
        return this.queryById(warehouseinfo.getWId());
    }

    /**
     * 通过主键删除数据
     *
     * @param wId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer wId) {
        return this.warehouseinfoDao.deleteById(wId) > 0;
    }
}